/**
  ******************************************************************************
  * @file    kea8_pwm.h
  * @author  花溪村长
  * @version V1.0
  * @date    4-11-2015
  * @brief   This file contains all the functions prototypes for the FTM 
  *          firmware library.
  ******************************************************************************
  * @attention  
  *
  ******************************************************************************
  */
	
#include "SKEAZ1284.h"    

#ifndef KEA128_FTM_H_
#define KEA128_FTM_H_

//FTM模块号
#define FTM_0 0
#define FTM_1 1
#define FTM_2 2
#define IS_FTM(ftmn) (ftmn == FTM0 || ftmn =FTM1 ||ftmn == FTM2)
//通道号，FTM0和FTM1：通道0~通道1，FTM2：通道0~通道5
#define CHANNEL0 0
#define CHANNEL1 1
#define CHANNEL2 2
#define CHANNEL3 3
#define CHANNEL4 4
#define CHANNEL5 5
#define IS_CHANNEL(nbit)  (nbit<6)


//FTM0 引脚
#define FTM0_CHANNEL0_PA0 (0<<8)
#define FTM0_CHANNEL0_PB2 (1<<8)

#define FTM0_CHANNEL1_PA1 (0<<9)
#define FTM0_CHANNEL1_PB3 (1<<9)

//FTM1引脚
#define FTM1_CHANNEL0_PC4 (0<<10)
#define FTM1_CHANNEL0_PH2 (1<<10)

#define FTM1_CHANNEL1_PC5 (0<<11)
#define FTM1_CHANNEL1_PE7 (1<<11)


//FTM2 引脚
#define FTM2_CHANNEL0_PC0 (0<<0)
#define FTM2_CHANNEL0_PH0 (1<<0)
#define FTM2_CHANNEL0_PF0 (2<<0)

#define FTM2_CHANNEL1_PC1 (0<<2)
#define FTM2_CHANNEL1_PH1 (1<<2)
#define FTM2_CHANNEL1_PF1 (2<<2)

#define FTM2_CHANNEL2_PC2 (0<<4)
#define FTM2_CHANNEL2_PD0 (1<<4)
#define FTM2_CHANNEL2_PG4 (2<<4)

#define FTM2_CHANNEL3_PC3 (0<<6)
#define FTM2_CHANNEL3_PD1 (1<<6)
#define FTM2_CHANNEL3_PG5 (2<<6)

#define FTM2_CHANNEL4_PB4 (0<<8)
#define FTM2_CHANNEL4_PG6 (1<<8)


#define FTM2_CHANNEL4_PB5 (0<<9)
#define FTM2_CHANNEL4_PG7 (1<<9)



typedef struct
{
	uint16_t CHANNEL ;
	int16_t Frequency; //频率
	int16_t Duty ;    //占空比
  uint16_t PIN ;
}FTM_InitTypeDef;

void FTM_PWM_set_duty(FTM_Type *FTMx, uint8_t channel, float duty);
void FTM_PWM_Init(FTM_Type * FTMx,FTM_InitTypeDef *FTM_InitStruct);
#endif
